Fix: Enable HEAD resolution in git worktrees#741
Conversation
|
Claude finished @meekrosoft's task in 2m 19s —— View job PR Review: Fix HEAD resolution in git worktrees
Static AnalysisAll checks pass: Code ReviewProduction change ( Test (
TODO.md: Follows the repo's slice-tracking convention correctly. Minor Observations
SummaryClean, minimal, well-tested fix. The change is backward-compatible, the test covers the important code paths, and the PR follows the repo's TDD and slice conventions. Looks good to merge. 👍 |
Enable EnableDotGitCommonDir in go-git's PlainOpenWithOptions so that ref resolution follows the commondir chain. Without this, HEAD in a linked worktree points to a branch whose ref lives in the main repo's .git/refs, and go-git fails with "reference not found". Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
0b6c5d4 to
4b865da
Compare
|
I'd love to hear more about why this is useful? and what was happening without it? |
|
Reply to @tooky 's comment: the make demo command doesn't work inside the worktree - the repo_root() command in the shell scripts that make the dummy data fail. |
Summary
Enable
EnableDotGitCommonDiroption ingitview.New()to properly resolve HEAD references in git worktrees.Changes
gitView.New()to usegit.PlainOpenWithOptions()withEnableDotGitCommonDir: trueTestNewGitViewFromWorktree()that validates:BranchName()returns correct branch in worktree contextGetCommitInfoFromCommitSHA("HEAD", ...)resolves correctly in worktreeImpact
Users can now use gitview operations from git worktree paths without errors when resolving HEAD references.